Conversation
Add a top-level `boxel run-command` command that executes host commands on the realm server via the `/_run-command` endpoint. Includes a programmatic `runCommand()` API and unit tests covering success, error, HTTP failure, network failure, missing profile, and malformed responses. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
so the important thing here is that this command needs to use the realm server token (vs the realm specific token). my LLM is always getting these 2 types of tokens confused. how are you managing the server token? |
|
|
||
| let response: Response; | ||
| try { | ||
| response = await pm.authedRealmServerFetch(url, { |
There was a problem hiding this comment.
how does this know to use the server token and not a realm specific token? and is there a test that can prove that by making sure these two tokens are actually different in the real realm test. (i find that the LLM gets confused here and tries to make these 2 the same token all the time)
There was a problem hiding this comment.
Do you mean that the LLM itself determines which tokens should be used? If so, it is not needed, because we store the realm server token and realm-specific tokens in the profile.json file, since they are generated after the LLM executes the boxel-profile command. Additionally, there are two fetch functions in the Boxel CLI, authedRealmServerFetch and authedRealmFetch, which are used by the commands to retrieve data using one of those two tokens, depending on the command.
There was a problem hiding this comment.
no. i mean the LLM that you are using to help you code this feature up. (assuming claude code). its really bad at telling the difference between server tokens and realm tokens. for me it's introduced dozens of bugs around this that have wasted many hours for me.
There was a problem hiding this comment.
ah i see--since you are using authedRealmServerFetch that is how we know to chose the correct token 👍
There was a problem hiding this comment.
Pull request overview
Adds a new boxel run-command top-level CLI command (plus a reusable runCommand() helper) to execute host commands on a realm server via the /_run-command endpoint, with accompanying integration coverage and a short implementation plan doc.
Changes:
- Introduces
runCommand()andregisterRunCommand()to POST JSON:API payloads to/_run-commandusingProfileManager.authedRealmServerFetch. - Registers the new
run-commandsubcommand in the CLI entrypoint. - Adds an integration test that spins up a test realm server and validates request shape + basic success path.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| packages/boxel-cli/src/commands/run-command.ts | Implements the new CLI command + exported helper that calls the realm-server /_run-command endpoint |
| packages/boxel-cli/src/index.ts | Registers the new command with the top-level Commander program |
| packages/boxel-cli/tests/integration/run-command.test.ts | Adds integration coverage for successful execution and request/URL shaping |
| docs/cs-10677-run-command-plan.md | Adds a short implementation plan for the feature |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Remove plan doc from repo (reviewer feedback) - Type Commander opts with RunCommandCliOptions interface - Validate --input is a plain JSON object (reject arrays/nulls/primitives) - Wrap response.json() in try/catch for malformed response handling - Add error-handling tests (non-2xx, invalid JSON, fetch throw) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
boxel run-command <specifier> --realm <url> [--input '{}'] [--json]CLI command that executes host commands on the realm server via the/_run-commandendpointrunCommand()function for use by other CLI commandsTest plan
pnpm vitest runinpackages/boxel-clipasses all new testsboxel run-command @cardstack/boxel-host/commands/get-card-type-schema/default --realm <url> --input '{"cardURL": "..."}'🤖 Generated with Claude Code